package de.smarthome.controllable;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import de.smarthome.ColorManagement.Colorbuilder;

public class JsonMapBuilder {

	private JsonMapBuilder() {
	}

	public static Map<String, Object> buildJsonMap(String item, int actColor) {
		Colorbuilder color = new Colorbuilder(actColor);
		Map<String, String> lightMap = new HashMap<String, String>();
		lightMap.put("red", color.getRed());
		lightMap.put("green", color.getGreen());
		lightMap.put("blue", color.getBlue());
		lightMap.put("fadeTime", "2");

		Map<String, Object> valueMap = new HashMap<String, Object>();

		valueMap.put("action", item);
		valueMap.put("values", new JSONObject(lightMap));
		valueMap.put("Id", "TEAM_AWESOME");
		valueMap.put("Version", null);

		return valueMap;
	}

	public static Map<String, Object> buildJsonMap(String item) {
		Map<String, Object> valueMap = new HashMap<String, Object>();

		valueMap.put("action", item);
		valueMap.put("values", new JSONObject(new HashMap<String, String>()));
		valueMap.put("Id", "TEAM_AWESOME");
		valueMap.put("Version", null);

		return valueMap;
	}

	public static Map<String, JSONArray> buildJsonMap(String winId, String position, String speed) {
		JSONArray jsonArray = new JSONArray();
		
		Map<String, JSONArray> valueMap = new HashMap<String, JSONArray>();

		
		jsonArray.put(position);
		jsonArray.put(speed);
		valueMap.put(winId, jsonArray);

		return valueMap;
	}

}
